import java.util.Queue;
import java.util.Scanner;

public class Test {
    public static void main(String[] args) {
        BinaryTree binaryTree = new BinaryTree();
        BinaryTree.TreeNode root = binaryTree.createTree();
        System.out.println(binaryTree.levelOrder2(root));
        System.out.println(binaryTree.isCompleteTree(root));
/*        Scanner scanner = new Scanner(System.in);
        while (scanner.hasNextInt()) { // 注意 while 处理多个 case
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            System.out.println(a + b);

        }*/
        //binaryTree.levelOrder(root);


       /* System.out.println("==");
        System.out.println("前序遍历");
        binaryTree.preOrder(root);
        System.out.println();
        System.out.println("中序遍历");
        binaryTree.inOrder(root);
        System.out.println();
        System.out.println("后序遍历");
        binaryTree.postOrder(root);
        System.out.println();*/
      /*  System.out.println("================");
        System.out.println("节点的个数");
        System.out.println(binaryTree.size(root));
        System.out.println(binaryTree.size2(root));
        System.out.println("叶子节点的个数");
        System.out.println(binaryTree.getLeafNodeCount2(root));
*/
        /*S*//*ystem.out.println(binaryTree.getKLevelNodeCount(root, 4));
        System.out.println(binaryTree.getHeight(root));*/

    }

}

/*
另一棵树的子树
class Solution {
    public boolean isSubtree(TreeNode root, TreeNode subRoot) {
        if(root == null) {
            return false;
        }
        if(isSameTree(root,subRoot)) {
            return true;
        }
        if(isSubtree(root.left,subRoot)) {
            return true;
        }
        if(isSubtree(root.right,subRoot)) {
            return true;
        }
        return false;

    }
    public boolean isSameTree(TreeNode p,TreeNode q) {
        if(p == null && q == null) {
            return true;
        }
        if(p != null && q == null || p == null && q != null) {
            return false;
        }
        if(p.val != q.val) {
            return false;
        }
        return isSameTree(p.left,q.left) && isSameTree(p.right,q.right);

    }
}
 */
/*
翻转二叉树
class Solution {
    public TreeNode invertTree(TreeNode root) {
        if(root == null) {
            return null;
        }
        if(root.left == null && root.right == null) {
            return root;
        }
        TreeNode tmp = null;
        tmp = root.left;
        root.left = root.right;
        root.right = tmp;
        invertTree(root.left);
        invertTree(root.right);
        return root;
    }
}
 */
